<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>角色指派</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__ADMIN_STATIC__/css/oksub.css">
	<script type="text/javascript" src="__STATIC__/lib/loading/okLoading.js"></script>

</head>
<body>
<div class="ok-body">
	<div class="layui-row">
		<div class="layui-col-md4">
			<div class="layui-card">
				<div class="layui-card-header">
					<div class="ok-card-title">用户信息</div>
				</div>
				<div class="ok-card-body map-body">
					<table class="layui-table">
						<thead>
						<tr>
							<th>参数</th>
							<th>参数值</th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td>用户名</td>
							<td>{$model.username}</td>
						</tr>
						<tr>
							<td>昵称</td>
							<td>{$model.nickname}</td>
						</tr>
						<tr>
							<td>头像</td>
							<td><img width="100" height="100" src="{$model.avatarUrl}" alt=""></td>
						</tr>
						<tr>
							<td>创建时间</td>
							<td>{$model.create_time}</td>
						</tr>
						<tr>
							<td>修改时间</td>
							<td>{$model.update_time}</td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="layui-col-md8">
			<div class="layui-card">
				<div class="layui-card-header">
					<div class="ok-card-title">指派角色</div>
				</div>
				<div class="ok-card-body map-body">
					<!--form表单-->
					<form class="layui-form layui-form-pane ok-form">
						<div class="layui-form-item" pane="">
							<label class="layui-form-label">可用角色</label>
							<div class="layui-input-block">
								{foreach $allRoles as $k=>$v }
								<input {in name="k" value="$related"}checked="checked"{/in} type="checkbox" value="{$k}" name="roles[]" lay-skin="primary" title="{$v}">
								{/foreach}
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block">
								<button class="layui-btn" lay-submit lay-filter="save">立即提交</button>
								<button type="reset" class="layui-btn layui-btn-primary">重置</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>

</div>
<!--js逻辑-->
<script src="__STATIC__/lib/layui/layui.js"></script>
<script>
	layui.use(["form", "okUtils", "okLayer"], function () {
		let form = layui.form;
		let okUtils = layui.okUtils;
		let okLayer = layui.okLayer;
		okLoading.close();
		form.on("submit(save)", function (data) {
			okUtils.ajax("{:url('user/saveAssignment',['id'=>$model->id])}", "post", data.field, true).done(function (response) {
				okLayer.greenTickMsg(response.msg, function () {
					parent.layer.close(parent.layer.getFrameIndex(window.name));
				});
			}).fail(function (error) {
				console.log(error)
			});
			return false;
		});
	});
</script>
</body>
</html>
